#ifndef ISO8583_H
#define ISO8583_H

#include "BitArray.h"
#include "FieldManager.h"

namespace suxw
{
    class ISO8583
    {
    public:
        ISO8583(void);

        //get data element
        bool getDE(int id, unsigned char *pcData, int &pnLen);
        //set data element
        bool setDE(int id, unsigned char *pcData, int nLen);
        //parse 8583
        bool parse(unsigned char *pcBuf, int nLen);

        //init 8583 protocol format
        virtual bool init8583() = 0;
    
    private:
        static const int MAX_BUF_SIZE = 4 * 1024;
        static const int MAX_FIELD_COUNT = 128;

        unsigned char m_szISO8583Buf[ISO8583::MAX_BUF_SIZE];
        int m_nBagLen;  //length of 8583 bag
        BitArray m_bitMap;

    protected:
        FieldManager* m_szFieldManager[MAX_FIELD_COUNT];
    };
}

#endif //ISO8583_H
